#Eric Hook
#hooke@onid.oregonstate.edu
#CS362 Winter 2014
#Assignment05 testDominion makefile

CC = gcc

CFLAGS = -Wall -fpic -coverage -lm -std=gnu99

default: testDominion

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

interface.o: interface.h interface.c dominion.o
	gcc -c interface.c -g  $(CFLAGS)

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

testdominion.o: testDominion dominion.o rngs.o
	gcc -c testdominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDominion: testDominion.o dominion.o rngs.o interface.o
	gcc -o testDominion testDominion.c -g dominion.o rngs.o interface.o $(CFLAGS)
	echo "testDominion.c:" > testDominion.out
	./testDominion 100
	gcov -b -c testDominion.c >> testDominion.out
	echo "dominion.c:" >> testDominion.out
	gcov -b -c dominion.c >> testDominion.out

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testBuyCard.c dominion.o rngs.o
	gcc -o testBuyCard -g  testBuyCard.c dominion.o rngs.o $(CFLAGS)

#################################################################

testUpdateCoins: testUpdateCoins.c dominion.o rngs.o
	gcc -o testUpdateCoins -g  testUpdateCoins.c dominion.o rngs.o $(CFLAGS)

#################################################################

unittestresults.out : unittest1.c unittest2.c unittest3.c unittest4.c cardtest1.c cardtest2.c cardtest3.c cardtest4.c rngs.c dominion.c
	echo "Result for running unit tests:" > unittestresults.out
	
	echo "unittest1.c:" >> unittestresults.out
	gcc -o unittest1 rngs.c dominion.c unittest1.c $(CFLAGS)
	echo "unittest1.c 1:" >> unittestresults.out
	# remove the ./ when upload to OSU server
	./unittest1 >> unittestresults.out
	gcov -b -c dominion.c >> unittestresults.out
	
	echo "unittest2.c:" >> unittestresults.out
	gcc -o unittest2 rngs.c dominion.c unittest2.c $(CFLAGS)
	echo "unittest2.c 2:" >> unittestresults.out
	# remove the ./ when upload to OSU server
	./unittest2 >> unittestresults.out
	gcov -b -c dominion.c >> unittestresults.out
	
	echo "unittest3.c:" >> unittestresults.out
	gcc -o unittest3 rngs.c dominion.c unittest3.c $(CFLAGS)
	echo "unittest3.c 3:" >> unittestresults.out
	# remove the ./ when upload to OSU server
	./unittest3 >> unittestresults.out
	gcov -b -c dominion.c >> unittestresults.out
	
	echo "unittest4.c:" >> unittestresults.out
	gcc -o unittest4 rngs.c dominion.c unittest4.c $(CFLAGS)
	echo "unittest4.c 4:" >> unittestresults.out
	# remove the ./ when upload to OSU server
	./unittest4 >> unittestresults.out
	gcov -b -c dominion.c >> unittestresults.out

#################################################################

	echo "cardtest1.c:" >> unittestresults.out
	gcc -o cardtest1 rngs.c dominion.c cardtest1.c $(CFLAGS)
	echo "cardtest1.c 1:" >> unittestresults.out
	# remove the ./ when upload to OSU server
	./cardtest1 >> unittestresults.out
	gcov -b -c dominion.c >> unittestresults.out
	
	echo "cardtest2.c:" >> unittestresults.out
	gcc -o cardtest2 rngs.c dominion.c cardtest2.c $(CFLAGS)
	echo "cardtest2.c 2:" >> unittestresults.out
	# remove the ./ when upload to OSU server
	./cardtest2 >> unittestresults.out
	gcov -b -c dominion.c >> unittestresults.out
	
	echo "cardtest3.c:" >> unittestresults.out
	gcc -o cardtest3 rngs.c dominion.c cardtest3.c $(CFLAGS)
	echo "cardtest3.c 3:" >> unittestresults.out
	# remove the ./ when upload to OSU server
	./cardtest3 >> unittestresults.out
	gcov -b -c dominion.c >> unittestresults.out
	
	echo "cardtest4.c:" >> unittestresults.out
	gcc -o cardtest4 rngs.c dominion.c cardtest4.c $(CFLAGS)
	echo "cardtest4.c 4:" >> unittestresults.out
	# remove the ./ when upload to OSU server
	./cardtest4 >> unittestresults.out
	gcov -b -c dominion.c >> unittestresults.out

#################################################################

# testsOut: dominion.o testSuite.c
# 	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

# testAll: dominion.o testSuite.c
# 	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)


all: playdom player testDrawCard testBuyCard badTestDrawCard testUpdateCoins testsOut testDominion

clean:
	rm -f *.o playdom test player testDrawCard testBuyCard badTestDrawCard testUpdateCoins testDominion unittest1 unittest2 unittest3 unittest4 cardtest1 cardtest2 cardtest3 cardtest4 unittestresults.out *.gcov *.gcda *.gcno *.so *.dSYM unittestresults.out gameResults.out testDominion.out